package com.zhy.filter;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
/**
 * @desc springBoot整合Filter方式二
 * @author zhy
 *
 */
@SpringBootApplication
public class Application2 {
	public static void main(String[] args) {
		SpringApplication.run(Application2.class, args);
	}
	
	@Bean
	public ServletRegistrationBean getSecondServlet(){
		ServletRegistrationBean bean=new ServletRegistrationBean(new SecondServlet());
		bean.addUrlMappings("/second");
		return bean;
	}
	
	@Bean
	public ServletRegistrationBean getThirdServlet(){
		ServletRegistrationBean bean=new ServletRegistrationBean(new ThirdServlet());
		bean.addUrlMappings("/third");
		return bean;
	}
	
	@Bean
	public FilterRegistrationBean getSecondFilter(){
		FilterRegistrationBean bean= new FilterRegistrationBean(new SecondFilter());
		bean.addUrlPatterns("/*");
		bean.setOrder(1);
		return bean;
	}
	
	@Bean
	public FilterRegistrationBean getThirdFilter(){
		FilterRegistrationBean bean= new FilterRegistrationBean(new ThirdFilter());
		bean.addUrlPatterns("/*");
		bean.setOrder(2);
		return bean;
	}
}
